#include <iostream>
using namespace std;

int minSum(int a,int b,int c)
{
    if(a<b){
        if(a<c) return a;
    }
    else if(b<=a) 
    {
        if(b<c) return b;
    }
    return c;
}
int main() {
   int q;
   cin>>q;
   while (q--) {
        int a,b,c;
        int ans=0;
        cin>>a>>b>>c;
        int d=minSum(a, b, c);
        a-=d;
        b-=d;
        c-=d;
        ans+=2*d;
        if(b)
        ans+=b-1;
        cout<<ans<<endl;
   }
   return 0;
}
